package pr.iceworld.fernando.apigateway.web;

import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import pr.iceworld.fernando.apigateway.application.model.UserDetail;
import pr.iceworld.fernando.apigateway.application.service.UserServiceClient;

@RestController
@RequiredArgsConstructor
public class ApiGatewayController {

    private final UserServiceClient userServiceClient;

    @GetMapping("users/{username}")
    public UserDetail getUserDetail(final @PathVariable String username) {
        final UserDetail userDetail = userServiceClient.getUserDetail(username);
        userDetail.setPassword(null);
        return userDetail;
    }
    @GetMapping("users/getUserDetails")
    public PageInfo<UserDetail> getUserDetails(final String dateStart, final String dateEnd) {
        return userServiceClient.getUserDetails(dateStart, dateEnd);
    }

    @GetMapping("/")
    public String welcome() {
        return "WelCome-----------";
    }
}
